
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/combinatorics/subsets.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:26:06 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Subsets &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="subsets.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Gray Code" href="graycode.html" />
    <link rel="prev" title="Prufer Sequences" href="prufer.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="graycode.html" title="Gray Code"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="prufer.html" title="Prufer Sequences"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Combinatorics</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Subsets</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.combinatorics.subsets">
<span id="subsets"></span><span id="combinatorics-subsets"></span><h1>Subsets<a class="headerlink" href="#module-sympy.combinatorics.subsets" title="Permalink to this headline">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.combinatorics.subsets.</span></span><span class="sig-name descname"><span class="pre">Subset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">subset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">superset</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L7-L587"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a basic subset object.</p>
<p class="rubric">Explanation</p>
<p>We generate subsets using essentially two techniques,
binary enumeration and lexicographic enumeration.
The Subset class takes two arguments, the first one
describes the initial subset to consider and the second
describes the superset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">next_binary</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;b&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">prev_binary</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;c&#39;]</span>
</pre></div>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.bitlist_from_subset">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">bitlist_from_subset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">subset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">superset</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L492-L514"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.bitlist_from_subset" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the bitlist corresponding to a subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">bitlist_from_subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="go">&#39;0011&#39;</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.subset_from_bitlist" title="sympy.combinatorics.subsets.Subset.subset_from_bitlist"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subset_from_bitlist</span></code></a></p>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.cardinality">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">cardinality</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.cardinality" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of all possible subsets.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">cardinality</span>
<span class="go">16</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.subset" title="sympy.combinatorics.subsets.Subset.subset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset" title="sympy.combinatorics.subsets.Subset.superset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.size" title="sympy.combinatorics.subsets.Subset.size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset_size" title="sympy.combinatorics.subsets.Subset.superset_size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset_size</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.iterate_binary">
<span class="sig-name descname"><span class="pre">iterate_binary</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L67-L92"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.iterate_binary" title="Permalink to this definition">¶</a></dt>
<dd><p>This is a helper function. It iterates over the
binary subsets by <code class="docutils literal notranslate"><span class="pre">k</span></code> steps. This variable can be
both positive or negative.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">iterate_binary</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;d&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">iterate_binary</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.next_binary" title="sympy.combinatorics.subsets.Subset.next_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">next_binary</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.prev_binary" title="sympy.combinatorics.subsets.Subset.prev_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prev_binary</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.iterate_graycode">
<span class="sig-name descname"><span class="pre">iterate_graycode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L223-L246"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.iterate_graycode" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function used for prev_gray and next_gray.
It performs <code class="docutils literal notranslate"><span class="pre">k</span></code> step overs to get the respective Gray codes.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">iterate_graycode</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[1, 4]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">iterate_graycode</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[1, 2, 4]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.next_gray" title="sympy.combinatorics.subsets.Subset.next_gray"><code class="xref py py-obj docutils literal notranslate"><span class="pre">next_gray</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.prev_gray" title="sympy.combinatorics.subsets.Subset.prev_gray"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prev_gray</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.next_binary">
<span class="sig-name descname"><span class="pre">next_binary</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L94-L114"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.next_binary" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates the next binary ordered subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">next_binary</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;b&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">next_binary</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.prev_binary" title="sympy.combinatorics.subsets.Subset.prev_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prev_binary</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_binary" title="sympy.combinatorics.subsets.Subset.iterate_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_binary</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.next_gray">
<span class="sig-name descname"><span class="pre">next_gray</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L248-L265"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.next_gray" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates the next Gray code ordered subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">next_gray</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[1, 3]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_graycode" title="sympy.combinatorics.subsets.Subset.iterate_graycode"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_graycode</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.prev_gray" title="sympy.combinatorics.subsets.Subset.prev_gray"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prev_gray</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.next_lexicographic">
<span class="sig-name descname"><span class="pre">next_lexicographic</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L138-L181"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.next_lexicographic" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates the next lexicographically ordered subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">next_lexicographic</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;d&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">next_lexicographic</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.prev_lexicographic" title="sympy.combinatorics.subsets.Subset.prev_lexicographic"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prev_lexicographic</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.prev_binary">
<span class="sig-name descname"><span class="pre">prev_binary</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L116-L136"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.prev_binary" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates the previous binary ordered subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">prev_binary</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">prev_binary</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;c&#39;]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.next_binary" title="sympy.combinatorics.subsets.Subset.next_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">next_binary</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_binary" title="sympy.combinatorics.subsets.Subset.iterate_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_binary</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.prev_gray">
<span class="sig-name descname"><span class="pre">prev_gray</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L267-L284"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.prev_gray" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates the previous Gray code ordered subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">prev_gray</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[2, 3, 4, 5]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_graycode" title="sympy.combinatorics.subsets.Subset.iterate_graycode"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_graycode</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.next_gray" title="sympy.combinatorics.subsets.Subset.next_gray"><code class="xref py py-obj docutils literal notranslate"><span class="pre">next_gray</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.prev_lexicographic">
<span class="sig-name descname"><span class="pre">prev_lexicographic</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L183-L221"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.prev_lexicographic" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates the previous lexicographically ordered subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">prev_lexicographic</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;d&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span><span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">prev_lexicographic</span><span class="p">()</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;c&#39;]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.next_lexicographic" title="sympy.combinatorics.subsets.Subset.next_lexicographic"><code class="xref py py-obj docutils literal notranslate"><span class="pre">next_lexicographic</span></code></a></p>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.rank_binary">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">rank_binary</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.rank_binary" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the binary ordered rank.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span><span class="s1">&#39;b&#39;</span><span class="p">,</span><span class="s1">&#39;c&#39;</span><span class="p">,</span><span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">rank_binary</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">rank_binary</span>
<span class="go">3</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_binary" title="sympy.combinatorics.subsets.Subset.iterate_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_binary</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.unrank_binary" title="sympy.combinatorics.subsets.Subset.unrank_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">unrank_binary</span></code></a></p>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.rank_gray">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">rank_gray</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.rank_gray" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the Gray code ranking of the subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span><span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span><span class="s1">&#39;b&#39;</span><span class="p">,</span><span class="s1">&#39;c&#39;</span><span class="p">,</span><span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">rank_gray</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">rank_gray</span>
<span class="go">27</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_graycode" title="sympy.combinatorics.subsets.Subset.iterate_graycode"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_graycode</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.unrank_gray" title="sympy.combinatorics.subsets.Subset.unrank_gray"><code class="xref py py-obj docutils literal notranslate"><span class="pre">unrank_gray</span></code></a></p>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.rank_lexicographic">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">rank_lexicographic</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.rank_lexicographic" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the lexicographic ranking of the subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">rank_lexicographic</span>
<span class="go">14</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">rank_lexicographic</span>
<span class="go">43</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.size">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">size</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.size" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the size of the subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">size</span>
<span class="go">2</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.subset" title="sympy.combinatorics.subsets.Subset.subset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset" title="sympy.combinatorics.subsets.Subset.superset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset_size" title="sympy.combinatorics.subsets.Subset.superset_size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset_size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.cardinality" title="sympy.combinatorics.subsets.Subset.cardinality"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cardinality</span></code></a></p>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.subset">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">subset</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.subset" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the subset represented by the current instance.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;c&#39;, &#39;d&#39;]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset" title="sympy.combinatorics.subsets.Subset.superset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.size" title="sympy.combinatorics.subsets.Subset.size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset_size" title="sympy.combinatorics.subsets.Subset.superset_size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset_size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.cardinality" title="sympy.combinatorics.subsets.Subset.cardinality"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cardinality</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.subset_from_bitlist">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">subset_from_bitlist</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">super_set</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bitlist</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L467-L490"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.subset_from_bitlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the subset defined by the bitlist.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">subset_from_bitlist</span><span class="p">([</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="s1">&#39;0011&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;c&#39;, &#39;d&#39;]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.bitlist_from_subset" title="sympy.combinatorics.subsets.Subset.bitlist_from_subset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bitlist_from_subset</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.subset_indices">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">subset_indices</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">subset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">superset</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L558-L587"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.subset_indices" title="Permalink to this definition">¶</a></dt>
<dd><p>Return indices of subset in superset in a list; the list is empty
if all elements of <code class="docutils literal notranslate"><span class="pre">subset</span></code> are not in <code class="docutils literal notranslate"><span class="pre">superset</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">superset</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">4</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">subset_indices</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">superset</span><span class="p">)</span>
<span class="go">[1, 2, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">subset_indices</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span> <span class="n">superset</span><span class="p">)</span>
<span class="go">[]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">subset_indices</span><span class="p">([],</span> <span class="n">superset</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.superset">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">superset</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.superset" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the superset of the subset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">superset</span>
<span class="go">[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.subset" title="sympy.combinatorics.subsets.Subset.subset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.size" title="sympy.combinatorics.subsets.Subset.size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset_size" title="sympy.combinatorics.subsets.Subset.superset_size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset_size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.cardinality" title="sympy.combinatorics.subsets.Subset.cardinality"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cardinality</span></code></a></p>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.superset_size">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">superset_size</span></span><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.superset_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the size of the superset.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Subset</span><span class="p">([</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">superset_size</span>
<span class="go">4</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.subset" title="sympy.combinatorics.subsets.Subset.subset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.superset" title="sympy.combinatorics.subsets.Subset.superset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">superset</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.size" title="sympy.combinatorics.subsets.Subset.size"><code class="xref py py-obj docutils literal notranslate"><span class="pre">size</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.cardinality" title="sympy.combinatorics.subsets.Subset.cardinality"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cardinality</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.unrank_binary">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">unrank_binary</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rank</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">superset</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L516-L534"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.unrank_binary" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the binary ordered subset of the specified rank.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">unrank_binary</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">])</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;b&#39;]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_binary" title="sympy.combinatorics.subsets.Subset.iterate_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_binary</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.rank_binary" title="sympy.combinatorics.subsets.Subset.rank_binary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rank_binary</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.Subset.unrank_gray">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">unrank_gray</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rank</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">superset</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L536-L556"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.Subset.unrank_gray" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the Gray code ordered subset of the specified rank.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">Subset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">unrank_gray</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">])</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[&#39;a&#39;, &#39;b&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Subset</span><span class="o">.</span><span class="n">unrank_gray</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">])</span><span class="o">.</span><span class="n">subset</span>
<span class="go">[]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset.iterate_graycode" title="sympy.combinatorics.subsets.Subset.iterate_graycode"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterate_graycode</span></code></a>, <a class="reference internal" href="#sympy.combinatorics.subsets.Subset.rank_gray" title="sympy.combinatorics.subsets.Subset.rank_gray"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rank_gray</span></code></a></p>
</div>
</dd></dl>

</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.combinatorics.subsets.ksubsets">
<span class="sig-prename descclassname"><span class="pre">subsets.</span></span><span class="sig-name descname"><span class="pre">ksubsets</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/combinatorics/subsets.py#L590-L611"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.combinatorics.subsets.ksubsets" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the subsets of size <code class="docutils literal notranslate"><span class="pre">k</span></code> in lexicographic order.</p>
<p>This uses the itertools generator.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.combinatorics.subsets</span> <span class="kn">import</span> <span class="n">ksubsets</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">ksubsets</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">[(1, 2), (1, 3), (2, 3)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">ksubsets</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4),     (2, 5), (3, 4), (3, 5), (4, 5)]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.combinatorics.subsets.Subset" title="sympy.combinatorics.subsets.Subset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Subset</span></code></a></p>
</div>
</dd></dl>

</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="prufer.html"
                        title="previous chapter">Prufer Sequences</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="graycode.html"
                        title="next chapter">Gray Code</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/combinatorics/subsets.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="graycode.html" title="Gray Code"
             >next</a> |</li>
        <li class="right" >
          <a href="prufer.html" title="Prufer Sequences"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Combinatorics</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Subsets</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/combinatorics/subsets.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:26:07 GMT -->
</html>